package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.TravelCommend;
import cn.wolfcode.trip.base.mapper.TravelCommendMapper;
import cn.wolfcode.trip.base.query.TravelCommendQueryObject;
import cn.wolfcode.trip.base.service.ITravelCommendService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class TravelCommendServiceImpl implements ITravelCommendService {

    @Autowired
    private TravelCommendMapper travelCommendMapper;

    /**
     * 推荐游记页面分页/高级查询
     *
     * @param qo
     * @return
     */
    public PageInfo queryForList(TravelCommendQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize(), qo.getOrderBy());
        return new PageInfo(travelCommendMapper.queryForList(qo));
    }

    /**
     * 推荐游记更新
     * @param travelCommend
     */
    public void update(TravelCommend travelCommend) {
        travelCommendMapper.updateByPrimaryKey(travelCommend);
    }

    /**
     * 推荐游记保存
     * @param travelCommend
     */
    public void save(TravelCommend travelCommend) {
        travelCommendMapper.insert(travelCommend);
    }

    /**
     * aoo每周推荐和每月推荐
     * @param qo
     * @return
     */
    public PageInfo queryForApp(TravelCommendQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize(), qo.getOrderBy());
        return new PageInfo(travelCommendMapper.queryForApp(qo));
    }
}
